package lab02.test03;

public class Student {
    //定义Student类的属性,并定义为私有的（只能在Student类中使用）
    private float comGradle;
    private float mathGradle;
    private float englGradle;
    //定义空参和有参构造
    public Student() {
    }

    public Student(float comGradle, float mathGradle, float englGradle) {
        this.comGradle = comGradle;
        this.mathGradle = mathGradle;
        this.englGradle = englGradle;
    }
    //使用get，set方法对属性初始化
    public float getComGradle() {
        return comGradle;
    }

    public void setComGradle(float comGradle) {
        this.comGradle = comGradle;
    }

    public float getMathGradle() {
        return mathGradle;
    }

    public void setMathGradle(float mathGradle) {
        this.mathGradle = mathGradle;
    }

    public float getEnglGradle() {
        return englGradle;
    }

    public void setEnglGradle(float englGradle) {
        this.englGradle = englGradle;
    }
    //定义sum方法求学生的总分
    public void sum(){
        float sum = comGradle + mathGradle + englGradle;
        System.out.println("该学生的总分为：" + sum);
    }
    //定义average方法求学生的平均成绩
    public void average(){
        float average = (comGradle + mathGradle + englGradle)/3;
        System.out.println("该学生的平均成绩为：" + average);
    }
    //定义max方法求学生的最高分
    public void max(){
        float max = comGradle;
        if (max < mathGradle){
            max = mathGradle;
            if (max < englGradle){
                max = englGradle;
            }
        }else if (max < englGradle){
            max = englGradle;
        }
        System.out.println("该学生的最高分为:" + max);
    }
    //定义min方法求学生的最低分
    public void min(){
        float min = comGradle;
        if (min > mathGradle){
            min = mathGradle;
            if (min > englGradle){
                min = englGradle;
            }
        }else if (min > englGradle){
            min = englGradle;
        }
        System.out.println("该学生的最低分为:" + min);
    }
    //输出学生的信息
    @Override
    public String toString() {
        return "该学生的信息：" + "\n"+ "计算机：" + comGradle + "\n" + "数学："+ mathGradle + "\n" + "英语：" + englGradle;
    }
}
